bitkeeper revision 1.1159.1.182 (41553903CsSyg7DOBEoizwc3e0V0OA)
authorkaf24@freefall.cl.cam.ac.uk <kaf24@freefall.cl.cam.ac.uk>
Sat, 25 Sep 2004 09:23:15 +0000 (09:23 +0000)
committerkaf24@freefall.cl.cam.ac.uk <kaf24@freefall.cl.cam.ac.uk>
Sat, 25 Sep 2004 09:23:15 +0000 (09:23 +0000)
Move Xen evetchn chrdev to 10,201 so we don't conflict with tun.

linux-2.6.8.1-xen-sparse/include/asm-xen/evtchn.h
tools/python/xen/lowlevel/xu/xu.c

index d4c43ee91d0c8fdf229df72a4885c153828dd6b1..597dce83cd40f98c9ce87ef627116cbe190c582c 100644 (file)
@@ -72,8 +72,8 @@ static inline void notify_via_evtchn(int port)
  * CHARACTER-DEVICE DEFINITIONS
  */
 
-/* /dev/xen/evtchn resides at device number major=10, minor=200 */
-#define EVTCHN_MINOR 200
+/* /dev/xen/evtchn resides at device number major=10, minor=201 */
+#define EVTCHN_MINOR 201
 
 /* /dev/xen/evtchn ioctls: */
 /* EVTCHN_RESET: Clear and reinit the event buffer. Clear error condition. */
index 813f3574640a85e41ff1bd31f80d6d2e90a7db04..9267d6596790e8477d7a4d357be329245e1678b1 100644 (file)
@@ -15,6 +15,7 @@
 #include <sys/socket.h>
 #include <sys/mman.h>
 #include <sys/poll.h>
+#include <sys/sysmacros.h>
 #include <netinet/in.h>
 #include <fcntl.h>
 #include <unistd.h>
@@ -37,7 +38,7 @@
 /* NB. The following should be kept in sync with the kernel's evtchn driver. */
 #define EVTCHN_DEV_NAME  "/dev/xen/evtchn"
 #define EVTCHN_DEV_MAJOR 10
-#define EVTCHN_DEV_MINOR 200
+#define EVTCHN_DEV_MINOR 201
 /* /dev/xen/evtchn ioctls: */
 /* EVTCHN_RESET: Clear and reinit the event buffer. Clear error condition. */
 #define EVTCHN_RESET  _IO('E', 1)
@@ -192,12 +193,19 @@ staticforward PyTypeObject xu_notifier_type;
 static PyObject *xu_notifier_new(PyObject *self, PyObject *args)
 {
     xu_notifier_object *xun;
+    struct stat st;
 
     if ( !PyArg_ParseTuple(args, "") )
         return NULL;
 
     xun = PyObject_New(xu_notifier_object, &xu_notifier_type);
 
+    /* Make sure any existing device file links to correct device. */
+    if ( (lstat(EVTCHN_DEV_NAME, &st) != 0) ||
+         !S_ISCHR(st.st_mode) ||
+         (st.st_rdev != makedev(EVTCHN_DEV_MAJOR, EVTCHN_DEV_MINOR)) )
+        (void)unlink(EVTCHN_DEV_NAME);
+
  reopen:
     xun->evtchn_fd = open(EVTCHN_DEV_NAME, O_NONBLOCK|O_RDWR);
     if ( xun->evtchn_fd == -1 )
@@ -205,7 +213,7 @@ static PyObject *xu_notifier_new(PyObject *self, PyObject *args)
         if ( (errno == ENOENT) &&
              ((mkdir("/dev/xen", 0755) == 0) || (errno == EEXIST)) &&
              (mknod(EVTCHN_DEV_NAME, S_IFCHR|0600, 
-                    (EVTCHN_DEV_MAJOR << 8) | EVTCHN_DEV_MINOR) == 0) )
+                    makedev(EVTCHN_DEV_MAJOR,EVTCHN_DEV_MINOR)) == 0) )
             goto reopen;
         PyObject_Del((PyObject *)xun);
         return PyErr_SetFromErrno(PyExc_IOError);